Private Sub cmdCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCopy.Click

    Dim lngFileSize As Long
    Dim intLoopCtr As Integer
    Dim intBufferCount As Integer
    Dim strInByte As String
    Dim strFrom_filename As String
    Dim strTo_filename As String
    Dim i As Integer, k As Integer
    'Set the length of the strInbyte string
    strInByte = Space(256)
    ' Set the from and to file copy paths
    strFrom_filename = "F:\temp\307312c2.doc"
    strTo_filename = "F:\temp\Copy of 307312c2.doc"
    ' If the destination file exists, ask the user if they
    ' want to continue
    If Dir(strTo_filename) <> "" Then
        If MsgBox(strTo_filename & vbCrLf & _
            " already exists. Copy over old file?", _
                 MsgBoxStyle.OKCancel) = MsgBoxResult.Cancel Then
                Exit Sub
        End If
    End If

    ' Get the size of the file to copy
    ' and calculate the number of times to loop
    ' the copy routine based on moving 256 bytes at a time
    lngFileSize = FileLen(strFrom_filename)
    intBufferCount = lngFileSize / 256

    ' Set the progressbar min and max properties
    prgStatus.Minimum = 1
    prgStatus.Maximum = 1 + intBufferCount

    ' Open the source and destination files
    FileOpen(1, strFrom_filename, OpenMode.Binary)
    FileOpen(2, strTo_filename, OpenMode.Binary)

    ' Set the label to display the file being copied
    ' and make all of the related controls visible
    lblDisplay.Text = "Copying.. " & strFrom_filename
    lblDisplay.Visible = True
    prgStatus.Visible = True

    ' This routine loops until the entire file is copied
    For intLoopCtr = 1 To intBufferCount + 1
        FileGet(1, strInByte)
        FilePut(2, strInByte)
        ' change progressbar value to indicate the status of
        ' the copy function
        prgStatus.Value = intLoopCtr

        ' the DoEvents command allows Windows to update
        ' the controls on the form
        Application.DoEvents()

        'Slow the program down to see the progressbar in action
        For i = 1 To 60000
            k = 1
        Next

    Next intLoopCtr

    ' After the copy is complete close both files
    FileClose(1)     ' Close file.
    FileClose(2)     ' Close file.

    ' Stop the animation and make all related controls
    ' invisible
    prgStatus.Visible = False
    lblDisplay.Visible = False

    ' Inform the user that the function is complete
    MsgBox("Copy function complete", MsgBoxStyle.Information)
End Sub
